package cn.eeepay.framework.service.workOrder;

import cn.eeepay.framework.db.pagination.Page;
import cn.eeepay.framework.model.UserInfo;
import cn.eeepay.framework.model.UserLoginInfo;
import cn.eeepay.framework.model.workOrder.WorkFlowNode;
import cn.eeepay.framework.model.workOrder.WorkOrder;
import cn.eeepay.framework.model.workOrder.WorkOrderUser;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Date;
import java.util.List;

/**
 * @author ：quanhz
 * @date ：Created in 2020/4/28 10:32
 */
public interface WorkOrderService {
    int del(Long id);

    WorkOrder insert(WorkOrder info);

    void update(WorkOrder info);

    List<WorkOrder> query(Page<WorkOrder> page, WorkOrder info);

    /**
     * 获取工单
     * @param id
     * @return
     */
    WorkOrder getWorkOrderById(Long id);

    /**
     * 获取当前部门所有用户
     * @return
     */
    List<UserInfo> getCurrentDeptUser();

    /**
     * 获取工单
     * @param orderNo
     * @return
     */
    WorkOrder getWorkOrderByOrderNo(String orderNo);

    /**
     * 获取工单驳回明细
     * @param id
     * @return
     */
    WorkOrder getWorkOrderToRejectById(Long id);

    /**
     * 获取工单明细
     * @param id
     * @return
     */
    WorkOrder getWorkOrderDetailById(Long id);

    /**
     * 关闭工单
     * @param id
     */
    void close(Long id);

    /**
     * 获取所有代办事项总数
     * @return
     */
    int getToDo();

    WorkOrder getWorkOrderToExport(WorkOrder order);

    void export(WorkOrder order, HttpServletResponse response, HttpServletRequest request);

    /***
     * 是否显示代理商可见
     * @param id
     * @return
     */
    boolean showAgentShow(Long id);


    /**
     * 回复权限判断
     * @param order
     * @param userLoginInfo
     * @param workUser
     * @param node
     * @return
     */
    boolean replyStatusCheck(WorkOrder order, UserLoginInfo userLoginInfo, WorkOrderUser workUser, WorkFlowNode node);

    /**
     * 关闭权限判断
     * @param order
     * @param userLoginInfo
     * @param workUser
     * @return
     */
    boolean closeStatusCheck(WorkOrder order, UserLoginInfo userLoginInfo, WorkOrderUser workUser);

    /**
     * 驳回权限判断
     * @param order
     * @param userLoginInfo
     * @param workUser
     * @param node
     * @return
     */
    boolean rejectStatusCheck(WorkOrder order, UserLoginInfo userLoginInfo, WorkOrderUser workUser, WorkFlowNode node);

    /**
     * 备注权限判断
     * @param order
     * @param userLoginInfo
     * @param workUser
     * @param node
     * @return
     */
    boolean remarkStatusCheck(WorkOrder order, UserLoginInfo userLoginInfo, WorkOrderUser workUser, WorkFlowNode node);


    boolean transferStatusCheck(WorkOrder order, UserLoginInfo userLoginInfo, WorkOrderUser workUser, WorkFlowNode node);

    /**
     * 明细权限判断
     * @param order
     * @param userLoginInfo
     * @param workUser
     * @return
     */
    boolean detailStatusCheck(WorkOrder order, UserLoginInfo userLoginInfo, WorkOrderUser workUser);


    Boolean getCurrentWorkUser();

    /**
     *  判断是否锁单
     * @param node
     * @param userLoginInfo
     * @param order
     * @param remarkFlag
     * @return
     */
    boolean locked(WorkFlowNode node, UserLoginInfo userLoginInfo, WorkOrder order, boolean remarkFlag);

    /**
     * 统计一级代理商的工单
     * @param workProductType 工单业务类型
     * @param agentNo 代理商编号
     * @param begin 开始时间
     * @param end 结束时间
     * @return
     */
    int countOrdersOneAgent(String workProductType, String agentNo, Date begin, Date end);

    /**
     * 统计直属代理商的工单
     * @param workProductType 工单业务类型
     * @param agentNo 代理商编号
     * @param begin 开始时间
     * @param end 结束时间
     * @return
     */
    int countOrdersBelongAgent(String workProductType, String agentNo, Date begin, Date end);
}
